<?php
	$dg = App_Models_DaugiaModel::getInstance();
	$ShowPhienDau = $this->ShowPhienDau;
	$NguoiDauCaoNhat = $this->NguoiDauCaoNhat;
	
	$DonViTien = $this->donvitien;
	$LinkPage = $this->link_page;
	$ListMenu = $this->list_menu;
	
	$TimeCD = $this->TimeCountDown;
	$LoaiPD = $this->LoaiPhienDau;
	//print_r($TimeCD);
	
    $LinkAppHost = 'http://' . $_SERVER['SERVER_NAME'].Zend_Controller_Front::getInstance()->getRequest()->getRequestUri();
	$datenow = date("Y-m-d H:i:s");

	// $facebook = new Ishali_Facebook();
	// $fb = $facebook->getFB();		
	// $pages = $fb->api('/me');
?>
	


<div id="daugia">
		<img class="main_img" src="<?php echo APP_DOMAIN . '/application/layouts/tmpdaugia/images/upload/images/' . $ShowPhienDau[0]["urlhinh"] ?>" alt="nem" title="nem">
		<div id="content_dg">
            <p class="textstyle2 tensp_dg"><?php echo $ShowPhienDau[0]["tensp"]?></p>
			<!--
			<span class="textstyle1">Bắt đầu : </span> 
				<span class="textstyle2"><?php echo $dg->CatThoigian($ShowPhienDau[0]["tgbatdau"])?></span></br>
			
			<span class="textstyle1">Kết thúc : </span> 
				<span class="textstyle2"><?php echo $dg->CatThoigian($ShowPhienDau[0]["tgketthuc"])?></span></br>
			-->
			<?php
				
                if($ShowPhienDau[0]["tgketthuc"] > $datenow)
				{
					if($LoaiPD == 1)
						echo "<span class='textstyle1'>Phiên đấu giá này sẽ kết thúc sau : </span>";
					if($LoaiPD == 0)
						echo "<span class='textstyle1'>Phiên đấu giá này sẽ bắt đầu sau : </span>";
			?>
					<script type="text/javascript">
						$(function(){
							$('#counter').countdown({
								image: '<?php echo APP_DOMAIN . '/application/layouts/tmpdaugia/images/digits.png'?>',
								//startTime: '09:09:60:59'
								startTime: '<?php echo $TimeCD['ngay'].':'.$TimeCD['gio'].':'.$TimeCD['phut'].':'.$TimeCD['giay'];?>',
								timerEnd: function(){ location.reload(); }
							});
						});
					</script>
			
					<div class="count_down">
						<div id="counter"></div>
						<div class="desc">
							<div>Ngày</div>
							<div>Giờ</div>
							<div>Phút</div>
							<div>Giây</div>
						</div>
					</div>
			<?php } ?>
			<div class="clear"></div>
			<p>
				<span class="textstyle1">Giá tham khảo : </span> 
				<span class="textstyle2 gtk"><?php echo number_format($ShowPhienDau[0]["giaban"],0,',','.')?>đ</span>
			</p>
			<p>
				<span class="textstyle1">Tiết kiệm : </span> 
				<span class="textstyle2"><?php if(!isset($NguoiDauCaoNhat[0]["giadau"])) echo number_format(($ShowPhienDau[0]["giaban"] - $ShowPhienDau[0]["giakhoidiem"]),0,',','.'); else echo number_format(($ShowPhienDau[0]["giaban"] - $NguoiDauCaoNhat[0]["giadau"]),0,',','.') ?>đ (<?php if(!isset($NguoiDauCaoNhat[0]["giadau"])) echo $dg->TinhPhanTramGiam($ShowPhienDau[0]["giaban"],($ShowPhienDau[0]["giaban"] - $ShowPhienDau[0]["giakhoidiem"])); else echo $dg->TinhPhanTramGiam($ShowPhienDau[0]["giaban"],($ShowPhienDau[0]["giaban"] - $NguoiDauCaoNhat[0]["giadau"]));?>%)</span></br>
			</p>
			
			<p class="timebid"><span class="textstyle1"></span></p>
			<span class="giabid"><?php if(!isset($NguoiDauCaoNhat[0]["giadau"])) echo number_format($ShowPhienDau[0]["giakhoidiem"],0,',','.'); else echo number_format($NguoiDauCaoNhat[0]["giadau"],0,',','.')?>đ</span>
            
            <?php 
               
                if($ShowPhienDau[0]["tgketthuc"]>$datenow)
                
                {
            ?>
            <a href="<?php echo $LinkAppHost ?>"><img class="lammoi" src="<?php echo APP_DOMAIN . '/application/layouts/tmpdaugia/images/refresh.png'?>" alt="Refresh" title="Làm mới giá đấu"/></a>
            <?php } ?>
            <br/>
			<span class="textstyle1">Người dấu giá cuối : </span> 
			<span class="nguoibid">
			<?php 
				
				if(!isset($NguoiDauCaoNhat[0]["iduser"])) 
				{
					echo "";
				}
				else 
				{
					echo $NguoiDauCaoNhat[0]["hoten"];
				}

			?>
			</span><br/>
			<?php
			if(!isset($NguoiDauCaoNhat[0]["giadau"]))
			{
				$giadau = $ShowPhienDau[0]["giakhoidiem"] + $ShowPhienDau[0]["buocgia"];
			}
			else
			{
				$giadau = $NguoiDauCaoNhat[0]["giadau"] + $ShowPhienDau[0]["buocgia"];
			}
			?>
            <?php 
               
                if($ShowPhienDau[0]["tgketthuc"]>$datenow)
                
                {
            ?>
            <span class="textstyle1">Giá đấu tiếp theo: </span>
			<input class="price"  readonly="true" type="text" id="pricebid" name="pricebid" value="<?php echo number_format($giadau,0,',','.');?>đ"/>

			<input type="button" class="btn_daugia" onclick="ClickDauGia({idpd:'<?php echo $ShowPhienDau[0]["idpd"]?>'})" name="daugia" value="Đấu giá" /><br/>
			<input type="hidden" id="hd_idpd" value="<?php echo $ShowPhienDau[0]["idpd"]?>"/>
			<input type="hidden" id="hd_idgd" value="<?php echo $giadau; ?>"/>
			<?php
                }
                else
                echo "<p class='pdketthuc'>Phiên Đấu Đã Kết Thúc</p>";
            ?>
			<a class="dsnguoibid" href="javascript:;" onclick = "DanhSachDauGia({idpd:<?php echo $ShowPhienDau[0]["idpd"]?>})">Danh sách người đấu giá</a>
			<p class="chiase">
				<iframe src="//www.facebook.com/plugins/like.php?href=<?php echo $LinkPage;?>&amp;send=false&amp;layout=button_count&amp;width=106&amp;show_faces=false&amp;font&amp;colorscheme=light&amp;action=like&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:106px; height:21px;" allowTransparency="true"></iframe>
                <!--
				<a title="Chia sẻ trên Facebook" target="_blank" href="https://www.facebook.com/sharer/sharer.php?s=100&p[title]=<?php echo $ShowPhienDau[0]["titlechiase"]?>&p[url]=<?php echo LINK_APPS; ?>&p[images][0]=<?php echo APP_DOMAIN . '/application/layouts/tmpdaugia/images/upload/images/' . $ShowPhienDau[0]["urlhinh"] ?>&p[summary]=<?php echo $ShowPhienDau[0]["motachiase"]?>"><img alt="Facebook" src="http://ishali.com.vn/public/default/images/icon_facebook.png"></a>
                -->
				<?php
					//$linkshare = LINK_APPS.'?app_data='.$ShowPhienDau[0]["idpd"];
					$linkshare = "";
					$picture = APP_DOMAIN . '/application/layouts/tmpdaugia/images/upload/images/' . $ShowPhienDau[0]["urlhinh"];
				?>
				<a title="Chia sẻ trên Facebook" href="javascript:;" onclick="danglentuong(<?php echo "'".$ShowPhienDau[0]["titlechiase"] ."', '". $ShowPhienDau[0]["tensp"] ."', '". $ShowPhienDau[0]["motachiase"] ."', '". $linkshare ."', '". $picture ."'"?>)">
					<img alt="Facebook" src="http://ishali.com.vn/public/default/images/icon_facebook.png">
				</a>
				<!--danglentuong(title, cap, des, link, pic)-->
				<a title="Chia sẻ lên Zing Me" target="_blank" href="http://link.apps.zing.vn/share?u=<?php echo LINK_APPS; ?>"><img src="http://ishali.com.vn/public/default/images/small_zing_icon.png"/></a>
            	<a title="Chia sẻ trên Google" target="_blank" href="https://plus.google.com/share?url=<?php echo LINK_APPS; ?>"><img alt="Google +1" src="http://ishali.com.vn/public/default/images/icon_googleplus.jpg"></a>
            	
				<a href="https://twitter.com/share" class="twitter-share-button" data-url="<?php echo LINK_APPS; ?>">Tweet</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
			</p>
		</div>
	</div>

	<div id="detail">
	<?php 
	if($ListMenu != "")
	{
	$NoiDung = $this->noidung;
	?>
		<div id="menutab">
			<ul class="menutab">
				<?php 
					for($i=0; $i<count($ListMenu); $i++)
					{
				?>
					<li onclick="ChangeTabActive(1,<?php echo $i+1;?>)" class="childtab <?php if($i==0) echo 'active';?>" id="<?php echo $i+1;?>" ><a href="javascript:;"><?php echo $ListMenu[$i];?></a></li>
				<?php } ?>
				<!--
				<li onclick="ChangeTabActive(1,2)" class="childtab" id="2"><a href="javascript:;">Thông số</a></li>
				-->
			</ul>
		</div>
		<div id="listtab">
			<?php 
				for($i=0; $i<count($ListMenu); $i++)
				{
			?>
				<div class="ctntab" id="ctntab<?php echo $i+1;?>"><?php echo $NoiDung[$i];?></div>
			<?php } ?>
			<!--<div class="ctntab" id="ctntab2">2</div>-->
		</div>
<?php } ?>
	
	
	
	
	
        <div class="commentFB">
            <div id="fb-root"></div>
            <script>(function(d, s, id) {
              var js, fjs = d.getElementsByTagName(s)[0];
              if (d.getElementById(id)) return;
              js = d.createElement(s); js.id = id;
              js.src = "//connect.facebook.net/vi_VN/all.js#xfbml=1&appId=195198003958238";
              fjs.parentNode.insertBefore(js, fjs);
            }(document, 'script', 'facebook-jssdk'));</script>
            <div class="fb-comments" data-href="<?php echo $LinkAppHost ?>" data-width="758" data-num-posts="2"></div>
        </div>
	</div>
